package org.example.bookshelf_manager.model;

import lombok.Data;
import org.example.bookshelf_manager.enums.ResultStatus;

/**
 * @ClassName Result
 * @Description
 * @Author ZJX
 * @Date 2024/8/31 17:17
 * @Version 1.0
 */
@Data
public class Result <T>{
    private int code; // 业务状态码
    private String errorMessage;
    private T data;

    public static <T> Result success(T data){
        Result result = new Result<>();
        result.setCode(ResultStatus.SUCCESS.getCode());
        result.setData(data);
        return result;
    }

    public static Result NoLogin(){
        Result result = new Result();
        result.setCode(ResultStatus.NOLOGIN.getCode());
        result.setErrorMessage("用户未登录");
        return result;
    }

}
